<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>编辑图书信息</title>
    <style>
        label{
            display: inline-block;
            width: 200px;
            text-align: right;
        }
    </style>
</head>
<body>
<div id="app">
    <label>编号</label><input v-model="book.id"><br>
    <label>书名</label><input v-model="book.bookname"><br>
    <label>出版社</label><input v-model="book.bookpress"><br>
    <label>出版日期</label><input v-model="book.pressdate"><br>
    <label>作者</label><input v-model="book.bookauthor"><br>
    <label>库存</label><input v-model="book.bookcount"><br>
    <label></label><button @click="save"></button>
</div>
<script>
    var v = new Vue({
        el : "#app",
        data :{
            book : {

            },
        },
        created (){
            var id = location.hash.substring(1);
            axios({
                url : "../GetBookServlet.do",
                params : {
                    id :id
                }
            }).then( res => {
                this.book = res.data;
            });
        },
        methods : {

            save(){
                axios({
                    url : "../SaveBookServlet.do",
                    params: this.book
                }).then(res =>{
                    alert(res.data);
                });
            }
        }
    });
</script>
</body>
</html>